﻿using Kingdee.BOS;
using Kingdee.BOS.WebApi.FormService;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WSDZ.KM.ZH.AttachmentUploadForm3
{
   public class FormApiHelper
    {
        public static bool AttachmentUpload(Context ctx,string json,ref string msg)
        {
            try
            {
                object resObj = WebApiServiceCall.AttachmentUpload(ctx, json);
                string objTxt = JsonConvert.SerializeObject(resObj);
                JObject returnData = JsonConvert.DeserializeObject<JObject>(objTxt);
                msg = returnData["Result"]["ResponseStatus"]["Errors"].ToStringV1();
                bool isok = returnData["Result"]["ResponseStatus"]["IsSuccess"].ToStringV1().ToBoolean();
                return isok;
            }
            catch (Exception ex)
            {
                msg = $@"异常【AU1001】【{ex.Message}】";
                return false;
            }
        }
        public static bool AttachmentUpload(Context ctx, string json, ref string msg,ref JObject returnData)
        {
            try
            {
                object resObj = WebApiServiceCall.AttachmentUpload(ctx, json);
                string objTxt = JsonConvert.SerializeObject(resObj);
                returnData = JsonConvert.DeserializeObject<JObject>(objTxt);
                msg = returnData["Result"]["ResponseStatus"]["Errors"].ToStringV1();
                bool isok = returnData["Result"]["ResponseStatus"]["IsSuccess"].ToStringV1().ToBoolean();
                return isok;
            }
            catch (Exception ex)
            {
                msg = $@"异常【AU1001】【{ex.Message}】";
                return false;
            }
        }
    }
}
